package com.gxh.controller.user;

import com.gxh.dto.PageQueryDTO;
import com.gxh.dto.UserHistoryDTO;
import com.gxh.result.PageResult;
import com.gxh.result.Result;
import com.gxh.service.UserHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("UserHistoryController")
@RequestMapping("/gxh/user/user_history")
@Api("用户历史记录接口")
@Slf4j
public class UserHistoryController {

    @Autowired
    private UserHistoryService userHistoryService;

    /**
     * 添加用户历史记录
     * @param userHistoryDTO
     * @return
     */
    @PostMapping
    @ApiOperation("添加用户历史记录")
    public Result add(@RequestBody UserHistoryDTO userHistoryDTO){
        log.info("添加用户历史记录{}", userHistoryDTO);
        userHistoryService.add(userHistoryDTO);
        return Result.success();
    }

    @GetMapping("/page")
    @ApiOperation("分页查询用户历史记录")
    public Result<PageResult> page(PageQueryDTO pageQueryDTO){
        log.info("分页查询用户历史记录{}", pageQueryDTO);
        PageResult pageResult = userHistoryService.userPage(pageQueryDTO);
        return Result.success(pageResult);
    }

}
